<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die('Restricted access');
?>

<?php  JHTML::_('behavior.tooltip');  ?>

<?php

	JToolBarHelper::title( JText::_( '&nbsp;&nbsp;&nbsp;'.JText::_( 'title_FAKTURY' ) ), 'faktury' );
  // JToolBarHelper::unarchiveList('unarchive','Odarchivovat');
  // JToolBarHelper::archiveList();
  JToolBarHelper::addNew();
	JToolBarHelper::editListX();
  JToolBarHelper::deleteList();

	
	//JToolBarHelper::preferences('com_jzmluvy', '500');
//	JToolBarHelper::help( 'screen.users' );
  $params	= &JComponentHelper::getParams('com_jzmluvy');

  
?>
<form action="index.php?option=com_jzmluvy" method="post" name="adminForm">
	<table>
		<tr>
			<td width="100%">
				<?php echo JText::_( 'FILTER' ); ?>:
				<input type="text" name="search" id="search" value="<?php echo htmlspecialchars($this->lists['search']);?>" class="text_area" onchange="document.adminForm.submit();" />
				<button onclick="this.form.submit();"><?php echo JText::_( 'POUZI' ); ?></button>
				<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_type').value='0';this.form.getElementById('filter_logged').value='0';this.form.submit();"><?php echo JText::_( 'ZRUSIT' ); ?></button>
			</td>
			<td nowrap="nowrap">
				<?php //echo $this->lists['anotace'];?>
        <?php // echo $this->lists['archiv'];?>
        <?php // echo $this->lists['kategorie'];?>				
			</td>
		</tr>
	</table>

	<table class="adminlist" cellpadding="1">
		<thead>
			<tr>
				<th width="2%" class="title">
					<?php echo JText::_( 'PORADIE' ); ?>
				</th>
				<th width="3%" class="title">
					<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?>);" />
				</th>
				<?php if($this->params->get( 'fv_dat_zverejnenia') && $this->params->get( 'ff_dat_zverejnenia')) : ?>
        <th width="3%" class="title">
					<?php echo JHTML::_('grid.sort',   JText::_( 'zm_EDIT_DAT_ZVEREJNENIA' ), 'ud.datZver', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th><?php endif; ?>
				<th width="5%" class="title" nowrap="nowrap">
					<?php echo JHTML::_('grid.sort',   JText::_( 'fa_EDIT_CISLO_FAK' ), 'ud.faktura', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
				<?php if($this->nastavenie->fak_int_cislo) : ?>
        <th width="5%" class="title" nowrap="nowrap">
					<?php echo JHTML::_('grid.sort',   JText::_( 'N_FAK_INT_CISLO' ), 'ud.intCislo', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th><?php endif; ?>        
				<th width="5%" class="title">
					<?php echo JHTML::_('grid.sort',   JText::_( 'fa_EDIT_DAT_DORUCENIA' ), 'ud.publish_up', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
				<th width="40%" class="title" >
					<?php echo JHTML::_('grid.sort',   JText::_( 'fa_EDIT_PREDMET' ), 'ud.title', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
        <th width="10%" class="title" >
          <?php echo JHTML::_('grid.sort',   JText::_( 'obj_HODNOTA_OBJ_PLNENIA' ), 'ud.suma', @$this->lists['order_Dir'], @$this->lists['order'] ); ?><br />
				  <?php echo JText::_( 'zm_SUMA' ); ?> <?php if($this->nastavenie->dph) { echo JText::_( 'OBJ_SDPH' ); } else { echo JText::_( 'OBJ_BEZDPH' ); } ?>
				</th>
        <th width="10%" class="title" >
					<?php echo JText::_( 'OBJ_IDENT_ZMLUVY' ) ?>
				</th>
        <th width="10%" class="title" >
					<?php echo JText::_( 'OBJ_IDENT_OBJEDNAVKY' ) ?>
				</th>
        <th class="title" nowrap="nowrap">
					<?php echo JHTML::_('grid.sort',   JText::_( 'fa_EDIT_PARTNER' ), 'ud.dodavatel', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>

<?php if($this->nastavenie->subory) :?>
				<th width="8%" class="title">
          <?php echo JText::_( 'fa_SUBOR' ); ?>
				</th>
        <?php endif ?>
				<!--
        <th width="5%" class="title">
					<?php echo JText::_( 'fa_STIAHNUTE' ); ?>
				</th> -->
<?php if($this->params->get( 'debug')) :?>  
				<th width="3%" class="title" nowrap="nowrap">
					<?php echo JHTML::_('grid.sort',   'ID', 'ud.id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
      <?php endif; ?>
        
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="12">
					<?php echo $this->pagination->getListFooter(); ?>
				</td>
			</tr>
		</tfoot>
<tbody>
		<?php
			$k = 0;
			for ($i=0, $n=count( $this->items ); $i < $n; $i++)
			{
				$row 	=& $this->items[$i];
				$link 	= 'index.php?option=com_jzmluvy&amp;view=upravafaktury&amp;hidemainmenu=1&amp;task=edit&amp;id[]='. $row->id. '';
        $link2 	= 'index.php?option=com_jzmluvy&amp;view=upravapartner&amp;hidemainmenu=1&amp;task=edit&amp;id[]='. $row->dodavatel. '';
        $link_zml 	= 'index.php?option=com_jzmluvy&amp;view=upravazmluvy&amp;hidemainmenu=1&amp;task=edit&amp;id[]='. $row->typ. '';
        $link_obj 	= 'index.php?option=com_jzmluvy&amp;view=upravaobjednavky&amp;hidemainmenu=1&amp;task=edit&amp;id[]='. $row->sposob. '';
			
        // kontola povinnych udajov
        if((empty($row->title)) || ($row->publish_up == 0) ||(empty($row->publish_up)) || (empty($row->dodavatel)) || (empty($row->mena)))
        {
        $chyba = jzmluvyHelper::obrazok('chyba-16.png','',JText::_( 'pa_chybny' ));
        }
        else 
        {
        $chyba = "";
        } 
        
      
      ?>
			<tr class="<?php echo "row$k"; ?>">
				<td>
					<?php echo $i+1+$this->pagination->limitstart;?>
				</td>
				<td>
					<?php echo JHTML::_('grid.id', $i, $row->id, '', 'id'); ?>
				</td>
        
        <?php if($this->params->get( 'fv_dat_zverejnenia') && $this->params->get( 'ff_dat_zverejnenia')) : ?>
				<td  align="right">
          <?php echo jzmluvyHelper::datdmy($row->datZver); ?>
				</td><?php endif ?>
				<td  align="right" nowrap="nowrap">
					<?php echo $row->faktura; ?>
				</td>
				<?php if($this->nastavenie->fak_int_cislo) : ?>
        <td  align="right" nowrap="nowrap">
					<?php echo $row->intCislo; ?>
				</td><?php endif ?>        
				<td  align="right">
          <?php echo jzmluvyHelper::datdmy($row->publish_up); ?>
				</td>
				<td>
           <a href="<?php echo $link; ?>">
						<?php echo $chyba.$row->title; ?></a>
					<div style="padding-left: 10px"><?php echo $row->fulltext; ?></div>
				</td>
					<td  align="right">
					<?php echo jzmluvyHelper::format_number($row->suma,',',' ')." ".$row->mena ; ?>
				</td>

        <td><?php //*** identifikacia zmluvy ?>
          <a href="<?php echo $link_zml; ?>">
          <?php if(($row->typ_zml) == '') { echo $row->zml_text; } else { echo $row->typ_zml; } ?></a>
          
          <?php if(!$row->jedCislo && $row->vlastni1 && $this->nastavenie->crz) : ?>
          <a href="http://<?php echo $row->vlastni1; ?>" target="_cr" title=""><?php echo $row->jedcislo; ?></a><?php echo "  ".jzmluvyHelper::obrazok('ext_link.png','',JText::_( 'pa_ext_link' )); ?>
          <?php elseif($this->nastavenie->crz) : ?>
          <?php echo $row->jedcislo; ?>
          <?php else : ?>
          <?php endif; ?>
        </td>

        <td>          
          <?php if(($row->sposob) != 0 ) : ?>
          <a href="<?php echo $link_obj; ?>">
          <?php if(($row->typ_obj) == '') { echo $row->obj_text; } else { echo $row->typ_obj; } ?></a>
          <?php endif;  ?>          
				</td>

        <td  nowrap="nowrap">
        <a href="<?php echo $link2; ?>">
        <?php echo $row->fadod; ?></a>
        </td>
        <?php if($this->nastavenie->subory) :?>
        <td align="center"><?php if (!empty($row->file)) echo $this->soubor ($row->id,$row->file,$row->filename,$row->extension); ?>
        <?php if (!empty($row->file2)) echo " ".$this->soubor2 ($row->id,$row->file2,$row->filename2,$row->extension2); ?>
        </td>
        <?php endif ?>
        <!-- <td align="center"><?php echo $row->hits.'x,'.$row->hits2.'x'; ?></td> -->
				<!-- <td><?php echo $row->catitle; ?></td> -->
        <?php if($this->params->get( 'debug')) :?>         
         <td>
					<?php echo $row->id; ?>
				</td>
        <?php endif; ?>
        
			</tr>
			<?php
				$k = 1 - $k;
				}
			?>
		</tbody>
	</table>
		<input type="hidden" name="option" value="com_jzmluvy" />
		<input type="hidden" name="view" value="faktura" />
		<input type="hidden" name="controller" value="upravafaktury" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="redirect" value="<?php //echo $redirect; ?>" />
		<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
		<?php echo JHTML::_( 'form.token' ); ?>
	</form>